/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Component;

import GameObject.StaticImage;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;

/**
 *
 * @author Huy
 */
public class MyLabel extends MyControlItem {

	String text;

	public MyLabel(String text, int x, int y) {
		sprite = new StaticImage(new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR), 1, 1, x, y);
		this.text = text;
	}
	public void setText(String text)
	{
		this.text = text;
	}
	@Override
	public void draw(Graphics2D g) {
		if (!isVisible) {
			return;
		}
		if (isEnable) {
			g.setColor(foreColor);
		} else {
			g.setColor(disableColor);
		}
		Rectangle2D textBound = g.getFont().getStringBounds(text, g.getFontRenderContext());
		Rectangle spriteBound = sprite.getBound();
		int y = (int) (spriteBound.y + textBound.getHeight());
		g.drawString(text, spriteBound.x, y);
		
	}
}
